﻿using System;
using System.Collections.Generic;

namespace Sasa.QualityTools.CodeAnalysis.Common.Tests.Unit.Instruments
{
    internal class CustomLogger : ILogger
    {
        private ICollection<string> buffer;

        private string prefix;


        internal CustomLogger(ICollection<string> buffer, string prefix)
        {
            this.buffer = buffer;
            this.prefix = prefix;
        }


        void ILogger.Info(string format, params object[] args)
        {
            buffer.Add(String.Format("[i] {0} ", prefix) + String.Format(format, args));
        }

        void ILogger.Warn(string format, params object[] args)
        {
            buffer.Add(String.Format("[w] {0} ", prefix) + String.Format(format, args));
        }

        void ILogger.Error(string format, params object[] args)
        {
            buffer.Add(String.Format("[e] {0} ", prefix) + String.Format(format, args));
        }

        void ILogger.Error(Exception exception, string format, params object[] args)
        {
            var message = String.Format(format, args);
            buffer.Add(String.Format("[ex] {0} {1} {2}", prefix, message, exception.Message));
        }
    }
}
